class ValidationError(Exception):
    def __init__(self, message, field=None, code=None):
        super().__init__(message)
        self.field = field
        self.code = code

    def __str__(self):
        if self.field:
            return f"字段 '{self.field}' 验证失败: {self.args[0]}"
        return self.args[0]